package com.zrong.gamesdk.test.integration.testcase;

import java.util.ArrayList;
import java.util.List;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransport;
import org.junit.Before;
import org.junit.Test;

public class CommonCommentTestCase {
	CommonCommentClient.Client client;

	@Before
	public void setup() throws Exception {
		TTransport transport = new THttpClient(
				"http://localhost:8080/UserPartake/service/thrift/commonComment");
		TProtocol protocol = new TBinaryProtocol(transport);
		client = new CommonCommentClient.Client(protocol);
	}
	@Test
    public void testQueryCommonComment() {
        List<String> commentOrigins = new ArrayList<String>();
        commentOrigins.add(String.valueOf(OriginsType.WWW.getValue()));
        commentOrigins.add(String.valueOf(OriginsType.WAP.getValue()));
        try {
            CommonCommentPageResult pageResult = client.queryCommonComments("700010587100", commentOrigins,"1001", 20, 10);
            System.out.print("commentList size==" + pageResult.getCommentList().size());
            System.out.print("pageResult size is " + pageResult.getTotal());
        } catch (ServiceRuntimeException e) {
            e.printStackTrace();
        } catch (TException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testCreateCommonComment() throws Exception {

        try {
//            ExecutorService pool = Executors.newFixedThreadPool(4);
//            Runnable runnable1 = new CommonCommentThread("评论1", "700012217000", "001", 1000, 100);
//            Runnable runnable2 = new CommonCommentThread("评论2", "700010587000", "002", 1002, 200);
//            Runnable runnable3 = new CommonCommentThread("评论3", "700010795000", "003", 1003, 300);
//            Runnable runnable4 = new CommonCommentThread("评论4", "700010783000", "003", 1004, 400);
//            new Thread(runnable1).start();
//            new Thread(runnable2).start();
//            new Thread(runnable3).start();
//            new Thread(runnable4).start();
        } catch (Exception e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}
